1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module shumate.Map; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gobject.Signals; 30 private import gtk.AccessibleIF; 31 private import gtk.AccessibleT; 32 private import gtk.BuildableIF; 33 private import gtk.BuildableT; 34 private import gtk.ConstraintTargetIF; 35 private import gtk.ConstraintTargetT; 36 private import gtk.Widget; 37 private import shumate.Layer; 38 private import shumate.MapSource; 39 private import shumate.Viewport; 40 private import shumate.c.functions; 41 public import shumate.c.types; 42 private import std.algorithm; 43 44 45 /** 46 * The Map widget is a [class@Gtk.Widget] that show and allows interaction with 47 * the user. 48 * 49 * This is the base widget and doesn't have advanced features. You can check the 50 * [class@Shumate.SimpleMap] for a ready-to-use widget. 51 * 52 * By default, a [class@Shumate.Viewport] is created and can be accessed with 53 * [method@Shumate.Map.get_viewport]. 54 * 55 * Unless created with [ctor@Shumate.Map.new_simple], the widget doesn't hold any 56 * layer and won't show anything. A [class@Shumate.Layer] can be added or removed 57 * using the [method@Shumate.Map.add_layer] or [method@Shumate.Map.remove_layer] 58 * methods. 59 */ 60 public class Map : Widget 61 { 62 /** the main Gtk struct */ 63 protected ShumateMap* shumateMap; 64 65 /** Get the main Gtk struct */ 66 public ShumateMap* getMapStruct(bool transferOwnership = false) 67 { 68 if (transferOwnership) 69 ownedRef = false; 70 return shumateMap; 71 } 72 73 /** the main Gtk struct as a void* */ 74 protected override void* getStruct() 75 { 76 return cast(void*)shumateMap; 77 } 78 79 /** 80 * Sets our main struct and passes it to the parent class. 81 */ 82 public this (ShumateMap* shumateMap, bool ownedRef = false) 83 { 84 this.shumateMap = shumateMap; 85 super(cast(GtkWidget*)shumateMap, ownedRef); 86 } 87 88 /** 89 * Creates an instance of #ShumateMap. 90 * 91 * Returns: a new #ShumateMap ready to be used as a #GtkWidget. 92 * 93 * Throws: ConstructionException GTK+ fails to create the object. 94 */ 95 public this(bool simple = false) 96 { 97 auto __p = (simple ? shumate_map_new_simple() : shumate_map_new()); 98 99 if(__p is null) 100 { 101 throw new ConstructionException("null returned by new"); 102 } 103 104 this(cast(ShumateMap*) __p); 105 } 106 107 /** 108 */ 109 110 /** */ 111 public static GType getType() 112 { 113 return shumate_map_get_type(); 114 } 115 116 /** 117 * Adds a new layer to the view 118 * 119 * Params: 120 * layer = a #ShumateLayer 121 */ 122 public void addLayer(Layer layer) 123 { 124 shumate_map_add_layer(shumateMap, (layer is null) ? null : layer.getLayerStruct()); 125 } 126 127 /** 128 * Centers the map on these coordinates. 129 * 130 * Params: 131 * latitude = the longitude to center the map at 132 * longitude = the longitude to center the map at 133 */ 134 public void centerOn(double latitude, double longitude) 135 { 136 shumate_map_center_on(shumateMap, latitude, longitude); 137 } 138 139 /** 140 * Checks whether the view animates zoom level changes. 141 * 142 * Returns: TRUE if the view animates zooms, FALSE otherwise. 143 */ 144 public bool getAnimateZoom() 145 { 146 return shumate_map_get_animate_zoom(shumateMap) != 0; 147 } 148 149 /** 150 * Get the 'go-to-duration' property. 151 * 152 * Returns: the animation duration when calling [method@Map.go_to], 153 * in milliseconds. 154 */ 155 public uint getGoToDuration() 156 { 157 return shumate_map_get_go_to_duration(shumateMap); 158 } 159 160 /** 161 * Gets the view's state. 162 * 163 * Returns: the state. 164 */ 165 public ShumateState getState() 166 { 167 return shumate_map_get_state(shumateMap); 168 } 169 170 /** 171 * Get the #ShumateViewport used by this view. 172 * 173 * Returns: the #ShumateViewport 174 */ 175 public Viewport getViewport() 176 { 177 auto __p = shumate_map_get_viewport(shumateMap); 178 179 if(__p is null) 180 { 181 return null; 182 } 183 184 return ObjectG.getDObject!(Viewport)(cast(ShumateViewport*) __p); 185 } 186 187 /** 188 * Checks whether the view zooms on double click. 189 * 190 * Returns: TRUE if the view zooms on double click, FALSE otherwise. 191 */ 192 public bool getZoomOnDoubleClick() 193 { 194 return shumate_map_get_zoom_on_double_click(shumateMap) != 0; 195 } 196 197 /** 198 * Move from the current position to these coordinates. All tiles in the 199 * intermediate view WILL be loaded! 200 * 201 * Params: 202 * latitude = the longitude to center the map at 203 * longitude = the longitude to center the map at 204 */ 205 public void goTo(double latitude, double longitude) 206 { 207 shumate_map_go_to(shumateMap, latitude, longitude); 208 } 209 210 /** 211 * Adds @layer to @self above @next_sibling or, if @next_sibling is %NULL, at 212 * the bottom of the layer list. 213 * 214 * Params: 215 * layer = a #ShumateLayer 216 * nextSibling = a #ShumateLayer that is a child of @self, or %NULL 217 */ 218 public void insertLayerAbove(Layer layer, Layer nextSibling) 219 { 220 shumate_map_insert_layer_above(shumateMap, (layer is null) ? null : layer.getLayerStruct(), (nextSibling is null) ? null : nextSibling.getLayerStruct()); 221 } 222 223 /** 224 * Adds @layer to @self behind @next_sibling or, if @next_sibling is %NULL, at 225 * the top of the layer list. 226 * 227 * Params: 228 * layer = a #ShumateLayer 229 * nextSibling = a #ShumateLayer that is a child of @self, or %NULL 230 */ 231 public void insertLayerBehind(Layer layer, Layer nextSibling) 232 { 233 shumate_map_insert_layer_behind(shumateMap, (layer is null) ? null : layer.getLayerStruct(), (nextSibling is null) ? null : nextSibling.getLayerStruct()); 234 } 235 236 /** 237 * Removes the given layer from the view 238 * 239 * Params: 240 * layer = a #ShumateLayer 241 */ 242 public void removeLayer(Layer layer) 243 { 244 shumate_map_remove_layer(shumateMap, (layer is null) ? null : layer.getLayerStruct()); 245 } 246 247 /** 248 * Should the view animate zoom level changes. 249 * 250 * Params: 251 * value = a #gboolean 252 */ 253 public void setAnimateZoom(bool value) 254 { 255 shumate_map_set_animate_zoom(shumateMap, value); 256 } 257 258 /** 259 * Set the duration of the transition of [method@Map.go_to]. 260 * 261 * Params: 262 * duration = the animation duration, in milliseconds 263 */ 264 public void setGoToDuration(uint duration) 265 { 266 shumate_map_set_go_to_duration(shumateMap, duration); 267 } 268 269 /** 270 * Changes the currently used map source. #g_object_unref() will be called on 271 * the previous one. 272 * 273 * As a side effect, changing the primary map source will also clear all 274 * secondary map sources. 275 * 276 * Params: 277 * mapSource = a #ShumateMapSource 278 */ 279 public void setMapSource(MapSource mapSource) 280 { 281 shumate_map_set_map_source(shumateMap, (mapSource is null) ? null : mapSource.getMapSourceStruct()); 282 } 283 284 /** 285 * Should the view zoom in and recenter when the user double click on the map. 286 * 287 * Params: 288 * value = a #gboolean 289 */ 290 public void setZoomOnDoubleClick(bool value) 291 { 292 shumate_map_set_zoom_on_double_click(shumateMap, value); 293 } 294 295 /** 296 * Stop the go to animation. The view will stay where it was when the 297 * animation was stopped. 298 */ 299 public void stopGoTo() 300 { 301 shumate_map_stop_go_to(shumateMap); 302 } 303 304 /** 305 * The #ShumateMap::animation-completed signal is emitted when any animation in the view 306 * ends. This is a detailed signal. For example, if you want to be signaled 307 * only for go-to animation, you should connect to 308 * "animation-completed::go-to". And for zoom, connect to "animation-completed::zoom". 309 */ 310 gulong addOnAnimationCompleted(void delegate(Map) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 311 { 312 return Signals.connect(this, "animation-completed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 313 } 314 }